<?php

namespace app\admin\model;
use think\Model;

class System extends Model
{
    public static function getValue($data)
    {
        $m = new static();
        $res = $m->where(['name'=>$data])->value('value');
        return unserialize($res);
    }
    public function updateConfig()
    {
        $config_type = input('post.config_type');
        $data['value'] = serialize(input($config_type.'/a'));

        if($this->where(['name'=>$config_type])->count() > 0){
            if($this->save($data,['name'=>$config_type]) !== false){
                return ajax_return(1,'提交成功');
            }else{
                return ajax_return(0,'提交失败');
            }
        }else{
            $data['name'] = $config_type;
            if($this->save($data) !== false){
                return ajax_return(1,'提交成功');
            }else{
                return ajax_return(0,'提交失败');
            }
        }
    }
}